FROM php:5.6-fpm-alpine

### (libpng-dev) gd, (imagemagick-dev) imagick, (libmcrypt-dev) mcrypt, (libmemcached-dev) memcached,
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories \
    && apk update && apk upgrade \
    && apk add git openssh autoconf \
    && apk add --no-cache build-base autoconf freetype-dev libpng-dev libjpeg-turbo-dev imagemagick-dev libmemcached-dev \
    && wget https://pecl.php.net/get/imagick-3.4.4.tgz -O /tmp/imagick-3.4.4.tgz \
    && wget https://pecl.php.net/get/memcached-2.2.0.tgz -O /tmp/memcached-2.2.0.tgz \
    && wget https://pecl.php.net/get/redis-4.3.0.tgz -O /tmp/redis-4.3.0.tgz \
    && wget https://pecl.php.net/get/memcache-2.2.7.tgz -O /tmp/memcache-2.2.7.tgz \
    && pecl install /tmp/imagick-3.4.4.tgz /tmp/memcached-2.2.0.tgz /tmp/redis-4.3.0.tgz /tmp/memcache-2.2.7.tgz \
    && docker-php-ext-enable memcached redis memcache \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd bcmath calendar exif sockets dba mysql mysqli pcntl pdo pdo_mysql shmop sysvmsg sysvsem sysvshm \
    && rm -rf /var/cache/apk/* \
    && rm -rf tmp/* \
    && wget https://getcomposer.org/download/2.0.8/composer.phar -O /usr/local/bin/composer \
    && chmod +x /usr/local/bin/composer \
    && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/